
package com.nikmesoft.android.alwaysontime.adapters;

import java.util.List;

import com.nikmesoft.android.alwaysontime.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.nikmesoft.android.alwaysontime.models.Task;


public class TaskAdapter extends ArrayAdapter<Task>
{
	private int resourceID;

	public TaskAdapter(Context context, int resourceID,
			List<Task> objects)
	{
		super(context, resourceID, objects);
		this.resourceID = resourceID;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		Task item = getItem(position);
		View row = convertView;
		if (row == null)
		{
			LayoutInflater inflater;
			inflater = (LayoutInflater) getContext().getSystemService(
					Context.LAYOUT_INFLATER_SERVICE);
			row = inflater.inflate(this.resourceID, null);
		}

		//CheckBox chkStatusTask = (CheckBox) row.findViewById(R.id.chkStatusTask);
		ImageView imgStatusTask = (ImageView) row.findViewById(R.id.imgStatusTask);		
		TextView tvContentTask = (TextView) row.findViewById(R.id.tvContentTask);
		RatingBar rtbarTask = (RatingBar) row.findViewById(R.id.rtbarTask);
		TextView tvTimeDate = (TextView) row.findViewById(R.id.tvTimeDate);
		TextView tvTypeTask = (TextView) row.findViewById(R.id.tvTypeTask);
		//sound
		
		
		//chkStatusTask.setChecked(item.getStatus());
		imgStatusTask.setImageResource( item.getStatus() ? R.drawable.ic_task_checked : R.drawable.ic_task_notchecked);
		tvContentTask.setText(item.getContent());
		rtbarTask.setRating(item.getPriority());
		tvTimeDate.setText(item.getTime()+","+item.getDate());
		tvTypeTask.setText(item.getType());
		return row;
	}

}
